package com.vueapi.utils;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultUtils implements Serializable {

    /**
     * 状态码
     */
    private Integer code;
    /**
     * 异常提示消息
     */
    private String msg;
    /**
     * 返回参数
     */
    private Object data;

    public ResultUtils() {
    }

    public ResultUtils(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultUtils success(){
        return new ResultUtils(200,"success",null);
    }

    public static ResultUtils success(Object data){
        return new ResultUtils(200,"success",data);
    }

    public static ResultUtils success(String message,Object data){
        return new ResultUtils(200,message,data);
    }

    public static ResultUtils fail(){
        return new ResultUtils(400,"fail",null);
    }

    public static ResultUtils fail(String message){
        return new ResultUtils(400,message,null);
    }

    public static ResultUtils fail(int code, String message, Object data){
        return new ResultUtils(code,message,data);
    }



}
